{extend name="homeheader:header"/}
{block name="content"}
	<link rel="stylesheet" type="text/css" href="/home/css/order.css" />
	<body style="overflow-x: hidden;">
		<div class="order">
			<div class="top">
				<a href="javascript:history.back(-1)" class="back">
					<i class="iconfont">&#xe615;</i></a>
				我的订单
			</div>
			<div class="butt row">
				<a href="javascript:;" id="ordersuccess" class="col-xs-3">已付款</a>
				<a href="javascript:;" id="nopay" class="col-xs-3">未付款</a>
				<a href="javascript:;" id="cancel" class="col-xs-3">已取消</a>
			</div>
			<div class="wrap_bt">
				
			</div>
		</div>
	</body>
</html>
<script type="text/javascript">

	/* 页面进来--已付款 */
	var o_status = 2;
	$('#ordersuccess').addClass('on');
	$.post('/home/user/getUserOrder',{o_status:o_status},function(res){
		var data = res.data;
		var str = '';
		for(var i=0;i<data.length;i++){
			str += '<div class="goods" id='+data[i].id+'>'+
						'<div class="b_top container row">'+
							'<div class="le col-xs-3">'+
								'<img src="/upload/'+data[i].goods[0].g_pic.photos[0].url+'"/>'+
							'</div>'+
							'<div class="col-xs-9">'+
								'<h3>'+data[i].goods[0].g_name+'</h3>'+
								'<small>'+data[i].goods[0].g_description+'</small>'+
							'</div>'+
							'<div class="xiangyou_t"><i class="iconfont">&#xe619;</i></div>'+
						'</div>'+
						'<div class="mone">'+
							'<p>订单号：'+data[i].o_code+'</p>'+
							'<p>订单金额： <span>￥'+data[i].o_tprice+'</span></p>'+
						'</div>'+
					'</div>';
		}
		$('.wrap_bt').append(str);
		$('.goods').click(function(){
			var oid = $(this).attr('id');
			setTimeout(function(){
				window.location.href="/home/orders/haspayorder/?id="+oid;
			},500);
		});
	});


	/* 选项卡-已付款 */
	$('#ordersuccess').click(function(){
		$(this).addClass("on").siblings("a").removeClass("on");
		$('.wrap_bt').empty();
		var status = 2;
		$.post('/home/user/getUserOrder',{o_status:status},function(res){
			var data = res.data;
			// console.log(data);
			var str = '';
			for(var i=0;i<data.length;i++){
				str += '<div class="goods" id='+data[i].id+'><div class="b_top container row"><div class="le col-xs-3"><img src="/upload/'+data[i].goods[0].g_pic.photos[0].url+'"/></div><div class="col-xs-9"><h3>'+data[i].goods[0].g_name+'</h3><small>'+data[i].goods[0].g_description+'</small></div><div class="xiangyou_t"><i class="iconfont">&#xe619;</i></div></div><div class="mone"><p>订单号：'+data[i].o_code+'</p><p>订单金额： <span>￥'+data[i].o_tprice+'</span></p></div></div>';
			}
			$('.wrap_bt').append(str);
			$('.goods').click(function(){
				var oid = $(this).attr('id');
				setTimeout(function(){
					window.location.href="/home/orders/haspayorder/?id="+oid;
				},500);
			});
		});
	});

	/* 选项卡-未付款 */
	$('#nopay').click(function(){
		$(this).addClass("on").siblings("a").removeClass("on");
		$('.wrap_bt').empty();
		var status = 1;
		$.post('/home/user/getUserOrder',{o_status:status},function(res){
			var data = res.data;
			var str = '';
			for(var i=0;i<data.length;i++){
				str += '<div class="goods" id='+data[i].id+'><div class="b_top container row"><div class="le col-xs-3"><img src="/upload/'+data[i].goods[0].g_pic.photos[0].url+'"/></div><div class="col-xs-9"><h3>'+data[i].goods[0].g_name+'</h3><small>'+data[i].goods[0].g_description+'</small></div><div class="xiangyou_t"><i class="iconfont">&#xe619;</i></div></div><div class="mone"><p>订单号：'+data[i].o_code+'</p><p>订单金额： <span>￥'+data[i].o_tprice+'</span></p></div></div>';
			}
			$('.wrap_bt').append(str);

			$('.goods').click(function(){
				var oid = $(this).attr('id');
				setTimeout(function(){
					window.location.href="/home/orders/norder/?id="+oid;
				},500);
			});
		});
	});

	/* 选项卡-已取消 */
	$('#cancel').click(function(){
		$(this).addClass("on").siblings("a").removeClass("on");
		$('.wrap_bt').empty();	
		var status = 3;
		$.post('/home/user/getUserOrder',{o_status:status},function(res){
			var data = res.data;
			var str = '';
			for(var i=0;i<data.length;i++){
				str += '<div class="goods" id='+data[i].id+'><div class="b_top container row"><div class="le col-xs-3"><img src="/upload/'+data[i].goods[0].g_pic.photos[0].url+'"/></div><div class="col-xs-9"><h3>'+data[i].goods[0].g_name+'</h3><small>'+data[i].goods[0].g_description+'</small></div><div class="xiangyou_t"><i class="iconfont">&#xe619;</i></div></div><div class="mone"><p>订单号：'+data[i].o_code+'</p><p>订单金额： <span>￥'+data[i].o_tprice+'</span></p></div></div>';
			}
			$('.wrap_bt').append(str);
			$('.goods').click(function(){
				var oid = $(this).attr('id');
				setTimeout(function(){
					window.location.href="/home/orders/sorder/?id="+oid;
				},500);
			});
		});
	});	
</script>
{/block}